#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void Swap(int* a, int* b)
{
	int tamp = *a;
	*a = *b;
	*b = tamp;
}
int partition(int* arr, int left, int right)
{
	int tamp = arr[left];
	while (left < right)
	{
		while (left < right && arr[right] >= tamp)
		{
			right--;
		}
		if (left < right)
		{
			arr[left] = arr[right];
			left++;
		}

		while (left < right && arr[left] <= tamp)
		{
			left++;
		}
		if (left < right)
		{
			arr[right] = arr[left];
			right--;
		}
	}
	arr[left] = tamp;
	return left;
}
void QuickSort(int* arr, int left, int right)
{
	if (left >= right)
		return;
	int pivot = partition(arr, left, right);
	QuickSort(arr, left, pivot - 1);
	QuickSort(arr, pivot+1, right);
}
int main()
{
	int arr[] = { 12,23,32,25,27,31,36,9,75 };
	int n = sizeof(arr) / sizeof(arr[0]);
	QuickSort(arr, 0, n - 1);
	for (int i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}